//
//  HomePageDetailsViewController.m
//  ShiWuPai
//
//  Created by app on 16/11/29.
//  Copyright © 2016年 QQ:244987427. All rights reserved.
//

#import "HomePageDetailsViewController.h"
#import "NSString+FJAddition.h"

#import <UIKit+AFNetworking.h>
#import <Masonry.h>
@interface HomePageDetailsViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UILabel *likeCountLable;

@property (nonatomic ,strong) UIImageView *cardImageView;
@property (nonatomic ,strong) UIImageView *pubisherAvaratImageView;
@property (nonatomic ,strong) UILabel *publishNameLable;
@property (nonatomic ,strong) UILabel *dateLable;



@end

@implementation HomePageDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //NavigationItem
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"ic_back_dark_20x22_@2x.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)];
    // Do any additional setup after loading the view from its nib.
    self.automaticallyAdjustsScrollViewInsets=NO;

    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.tableHeaderView=[self HeaderView];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    self.likeCountLable.text=[NSString stringWithFormat:@"%ld",self.feed.likeCt];
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden=YES;
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.tabBarController.tabBar.hidden=NO;
}

#pragma mark - init views
-(UIView *)HeaderView {
    UIView *view=[[UIView alloc] init];
    view.bounds=CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-80);
    //pubisherAvaratImageView
    self.pubisherAvaratImageView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
    self.pubisherAvaratImageView.layer.cornerRadius=25;
    [self.pubisherAvaratImageView setImageWithURL:[NSURL URLWithString:self.feed.publisherAvatar] placeholderImage:nil];
    [view addSubview:self.pubisherAvaratImageView ];
    
    //publishNameLable
    self.publishNameLable=[[UILabel alloc]initWithFrame:CGRectMake(100, 10, 200, 20)];
    //self.publishNameLable.backgroundColor=[UIColor redColor];
    self.publishNameLable.text=self.feed.publisher;
    [view addSubview:self.publishNameLable];
    
    //dateLable
    self.dateLable=[[UILabel alloc] initWithFrame:CGRectMake(100, 40, 200, 20)];
    //self.dateLable.backgroundColor=[UIColor redColor];
    self.dateLable.text=@"2016-11-29";
    [view addSubview:self.dateLable];
    //
    self.cardImageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 80, self.view.bounds.size.width, view.bounds.size.height-80)];
    [self.cardImageView setImageWithURL:[NSURL URLWithString:self.feed.cardImage] placeholderImage:nil];
    [view addSubview:self.cardImageView];
    
    return view;
}

#pragma mark - event response
-(void)goBack:(UIBarButtonItem *)barButtonItem{
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)goodButtonPress:(UIButton *)sender {
}

#pragma mark - private method

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if ([self.feed.descriptionField isEmpty]) {
        return 0;
    }
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    cell.backgroundColor=[UIColor orangeColor];
    cell.textLabel.numberOfLines=0;
    cell.textLabel.text=self.feed.descriptionField;
    return cell;
}
#pragma mark - UITableViewDelegate



@end
